package util;

import java.sql.Timestamp;
import java.util.Calendar;

public class DateConvert {

	public static Timestamp convertToTimestamp(int annee, int mois, int jour, int heure, int minute) {
		Calendar cal = Calendar.getInstance();
	    cal.set(Calendar.YEAR, annee);
	    cal.set(Calendar.MONTH, mois);
	    cal.set(Calendar.DATE, jour);
	    cal.set(Calendar.HOUR_OF_DAY, heure);
	    cal.set(Calendar.MINUTE, minute);
	    cal.set(Calendar.SECOND, 0);
	    cal.set(Calendar.MILLISECOND, 0);
	    return new Timestamp(cal.getTimeInMillis());
	}
	
	public static Timestamp convertToTimestamp(String annee, String mois, String jour, String heure, String minute) {
		Calendar cal = Calendar.getInstance();
	    cal.set(Calendar.YEAR, Integer.parseInt(annee));
	    cal.set(Calendar.MONTH, Integer.parseInt(mois));
	    cal.set(Calendar.DATE, Integer.parseInt(jour));
	    cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(heure));
	    cal.set(Calendar.MINUTE, Integer.parseInt(minute));
	    cal.set(Calendar.SECOND, 0);
	    cal.set(Calendar.MILLISECOND, 0);
	    return new Timestamp(cal.getTimeInMillis());
	}
}
